﻿using MCPlatform.MotionLib.Base;
using MCPlatform.MotionLib.Base.AssitantClass;
using MCPlatform.MotionLib.Base.Models;
using MCPlatform.UI.Controls.AssistantMethods.StaticMethods;
using MCPlatform.UI.Controls.Converts;
using Panuon.WPF;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Timers;
using System.Windows.Input;

namespace MCPlatform.UI.Controls.Models
{
    public class ValveModel : NotifyPropertyChangedBase
    {
        #region Properties

        public IValve? ValveEntity { get => _ValveEntity; set => Set(ref _ValveEntity, value); }
        private IValve? _ValveEntity;

        /// <summary>
        /// 阀名称
        /// </summary>
        public string? ValveName
        {
            get => _ValveName;
            set => Set(ref _ValveName, value);
        }
        private string? _ValveName;


        /// <summary>
        /// 原位传感器输入
        /// </summary>
        public bool BaseIn
        {
            get => _BaseIn;
            set => Set(ref _BaseIn, value);
        }
        private bool _BaseIn;

        /// <summary>
        /// 工作位传感器输入
        /// </summary>
        public bool WorkIn
        {
            get => _WorkIn;
            set => Set(ref _WorkIn, value);
        }
        private bool _WorkIn;

        public bool BaseOut
        {
            get => _BaseOut;
            set => Set(ref _BaseOut, value);
        }
        private bool _BaseOut;

      
        public bool WorkOut
        {
            get => _WorkOut;
            set => Set(ref _WorkOut, value);
        }
        private bool _WorkOut;

      
        public ushort BaseInAddress
        {
            get => _BaseInAddress;
            set => Set(ref _BaseInAddress, value);
        }
        private ushort _BaseInAddress;

        /// <summary>
        /// 工作位IO地址
        /// </summary>
        public ushort WorkInAddress
        {
            get => _WorkInAddress;
            set => Set(ref _WorkInAddress, value);
        }
        private ushort _WorkInAddress;

            


        /// <summary>
        /// 原位IO地址
        /// </summary>
        public ushort BaseOutAddress
        {
            get => _BaseOutAddress;
            set => Set(ref _BaseOutAddress, value);
        }
        private ushort _BaseOutAddress;

        /// <summary>
        /// 工作位IO地址
        /// </summary>
        public ushort WorkOutAddress
        {
            get => _WorkOutAddress;
            set => Set(ref _WorkOutAddress, value);
        }
        private ushort _WorkOutAddress;




        #endregion

        #region Methods

        public void Mapping()
        {
            CommonUse.AutoMapProperties(ValveEntity, this);
        }

        #endregion


        #region Methods

        //Timer timer;
        //public void StartMappingEntityToModel()
        //{
        //    if (ValveEntity is null)
        //    {
        //        return;
        //    }

        //    timer.Start();


        //}


        //public void StopMappingEntityToModel()
        //{

        //    timer.Stop();


        //}

        #endregion

        #region CTOR

        //public ValveModel()
        //{
        //    timer = new Timer(200);
        //    timer.Elapsed += Timer_Elapsed;
        //}

        //private void Timer_Elapsed(object? sender, ElapsedEventArgs e)
        //{
        //    if (ValveEntity is null)
        //    {
        //        return;
        //    }
 
        //    this.Mapping();
        //}

        #endregion


       

    }
}
